package cn.tedu.csmall.product.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Component
public class TimerAspect {

    @Around("execution(* cn.tedu.csmall.product.service.*.*(..))")
    public Object timer(ProceedingJoinPoint pjp) throws Throwable{
        log.debug("开始执行业务方法！");
        long start = System.currentTimeMillis();
        Object result = pjp.proceed();
        long end = System.currentTimeMillis();
        log.debug("业务方法执行结束，耗时："+ (end - start));
        return result;
    }
}
